package com.jack.lib.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 作者: jack(黄冲)
 * 邮箱: 907755845@qq.com
 * create on 2018/9/25 9:56
 * 侧滑删除的ListView
 */

public class SideslipRecyclerView extends JRecyclerView {


    public SideslipRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        if(ev.getAction() == MotionEvent.ACTION_DOWN){
            if (SideslipView.mOldSideslipView != null){
                int[] ints = new int[2];
                SideslipView.mOldSideslipView.getLocationInWindow(ints);
                int height = SideslipView.mOldSideslipView.getHeight();

                if (ev.getRawY() < ints[1] || ev.getRawY() > ints[1] + height){
                    SideslipView.mOldSideslipView.closeMenu();
                    SideslipView.mOldSideslipView = null;
                    return false;
                }
            }
        }
        return super.dispatchTouchEvent(ev);
    }
}
